"""
34 - Dars BeautifulSoup
"""


import urllib.request
from bs4 import BeautifulSoup #pylint: disable=import-erro #pylint: disable=import-erro #pylint: disable=import-errorrr

# pip freeze - pipni muzlargichi
# pip3 install BeautifulSoup4 - Parser
# pip -v

REQ = urllib.request.urlopen('https://futbol24.com/') #pylint: disable=bad-option-value
HTML = REQ.read()
# print(BeautifulSoup(HTML))

SOUP = BeautifulSoup(HTML, 'html.parser')
NEWS = SOUP.find_all('div', class_="col-md-6")
print(SOUP.prettify())
print(NEWS)

RESULTS = []

for item in NEWS:
    title = item.find('div', class_='col-md-6')
    desc = item.find('div', class_='row')
    href = item.find('a', 'href')
    RESULTS.append({
        'title': title,
        'desc': desc,
        'href': href,
    })
print(RESULTS)

F = open('news.txt', 'w', encoding='utf-8') #pylint: disable=bad-option-value
i = 1
for item in RESULTS:
    F.write(f'Ноост {i}\n\nНазни: {item["ti"]}\nОписани: {item["de"]}\nСсылк: {item["hr"]}\n\n*\n')
    i += 1
F.close()
